package com.lagou.rpc.consumer.configuration;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;

@Configuration
public class RpcConfiguration {

//    @Bean
    public IUserService userServiceFactoryBean() {
        IUserService userService = (IUserService) RpcClientProxy.createProxy(IUserService.class);
        return userService;
    }

    @Bean
    public RpcScannerConfigurer rpcScannerConfigurerFactoryBean(){
        String beanName = "com.lagou.rpc.api.IUserService";
        RpcScannerConfigurer rpcScannerConfigurer = new RpcScannerConfigurer();
        ArrayList<String> beanNameList = new ArrayList<>();
        beanNameList.add(beanName);
        rpcScannerConfigurer.setBeanNameList(beanNameList);
        return rpcScannerConfigurer;
    }
}
